{
 "cells": [
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2025-03-03T01:53:08.250247Z",
     "start_time": "2025-03-03T01:53:06.745753Z"
    }
   },
   "source": [
    "#1.接口：daily\n",
    "\n",
    "from daily_warpper import *\n",
    "\n",
    "wrapper = DailyWarpper()\n",
    "\n",
    "params = {'ts_code':'000001.SZ','startdate':20180101,'enddate':20220226}\n",
    "df=wrapper.read_from_tushare(params) \n",
    "df.to_csv(\"daily_warpper.csv\")\n",
    "wrapper.write_to_db(params) \n",
    "\n",
    "print(df.head(5))"
   ],
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "数据库中的所有表：\n",
      "数据库中的所有表：\n",
      "000001.SZ 20180101 20220226\n",
      "cache missed: 000001.SZ is not in checkflags\n",
      "000001.SZ 20180101 20220226\n",
      "Table 'daily_000001_sz' created successfully.\n",
      "Data from dataframe has been written to the table daily_000001_sz.\n",
      "Data successfully written to table 'daily_000001_sz'.\n",
      "     ts_code trade_date   open   high    low  close  pre_close  change  \\\n",
      "0  000001.SZ   20220225  15.99  16.08  15.87  15.90      15.91   -0.01   \n",
      "1  000001.SZ   20220224  16.13  16.15  15.80  15.91      16.19   -0.28   \n",
      "2  000001.SZ   20220223  16.30  16.31  16.04  16.19      16.23   -0.04   \n",
      "3  000001.SZ   20220222  16.31  16.44  16.16  16.23      16.51   -0.28   \n",
      "4  000001.SZ   20220221  16.66  16.67  16.32  16.51      16.77   -0.26   \n",
      "\n",
      "   pct_chg         vol       amount  \n",
      "0  -0.0629   726397.07  1157890.268  \n",
      "1  -1.7295  1324086.85  2112842.553  \n",
      "2  -0.2465   886742.44  1431289.852  \n",
      "3  -1.6959   894956.73  1454156.224  \n",
      "4  -1.5504   800994.55  1316023.718  \n"
     ]
    }
   ],
   "execution_count": 1
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-03-03T01:57:25.095006Z",
     "start_time": "2025-03-03T01:57:24.755151Z"
    }
   },
   "cell_type": "code",
   "source": [
    "#2.接口：income\n",
    "\n",
    "from Income_warpper import *\n",
    "\n",
    "wrapper = IncomeWarpper()\n",
    "\n",
    "params = {'ts_code': '600000.SH', 'startdate': 20180101, 'enddate': 20190730}\n",
    "df = wrapper.read_from_tushare(params)  \n",
    "df.to_csv(\"income_warpper.csv\")\n",
    "wrapper.write_to_db(params)  \n",
    "\n",
    "print(df.head(5))"
   ],
   "id": "8e3fd9057171650e",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "数据库中的所有表：\n",
      "daily_000001_sz\n",
      "数据库中的所有表：\n",
      "daily_000001_sz\n",
      "600000.SH 20180101 20190730\n",
      "cache missed: 600000.SH is not in checkflags\n",
      "600000.SH 20180101 20190730\n",
      "Table 'income_600000_sh' created successfully.\n",
      "Data from dataframe has been written to the table income_600000_sh.\n",
      "Data successfully written to table 'income_600000_sh'.\n",
      "     ts_code  ann_date f_ann_date  end_date report_type comp_type end_type  \\\n",
      "0  600000.SH  20190430   20190430  20190331           1         2        1   \n",
      "1  600000.SH  20190326   20190326  20181231           1         2        4   \n",
      "2  600000.SH  20190326   20190326  20181231           1         2        4   \n",
      "3  600000.SH  20181031   20181031  20180930           1         2        3   \n",
      "4  600000.SH  20180830   20180830  20180630           1         2        2   \n",
      "\n",
      "   basic_eps  diluted_eps  total_revenue  ...  withdra_biz_devfund  \\\n",
      "0       0.53         0.53   5.008400e+10  ...                 None   \n",
      "1       1.85         1.85   1.715420e+11  ...                 None   \n",
      "2       1.85         1.85   1.715420e+11  ...                 None   \n",
      "3       1.44         1.44   1.271090e+11  ...                 None   \n",
      "4       0.95         0.95   8.225600e+10  ...                 None   \n",
      "\n",
      "   withdra_rese_fund withdra_oth_ersu  workers_welfare  distr_profit_shrhder  \\\n",
      "0               None             None             None                  None   \n",
      "1               None             None             None                  None   \n",
      "2               None             None             None                  None   \n",
      "3               None             None             None                  None   \n",
      "4               None             None             None                  None   \n",
      "\n",
      "   prfshare_payable_dvd  comshare_payable_dvd capit_comstock_div  \\\n",
      "0                  None                  None               None   \n",
      "1                  None                  None               None   \n",
      "2                  None                  None               None   \n",
      "3                  None                  None               None   \n",
      "4                  None                  None               None   \n",
      "\n",
      "  continued_net_profit update_flag  \n",
      "0         1.662500e+10           0  \n",
      "1         5.651500e+10           1  \n",
      "2         5.651500e+10           0  \n",
      "3         4.366400e+10           0  \n",
      "4         2.890000e+10           1  \n",
      "\n",
      "[5 rows x 85 columns]\n"
     ]
    }
   ],
   "execution_count": 2
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-03-03T01:58:42.375340Z",
     "start_time": "2025-03-03T01:58:41.944066Z"
    }
   },
   "cell_type": "code",
   "source": [
    "#3.接口：balancesheet\n",
    "\n",
    "from balancesheet_warpper import *\n",
    "\n",
    "wrapper = BalanceSheetWarpper()\n",
    "\n",
    "params = {'ts_code': '600000.SH', 'startdate': 20180101, 'enddate': 20190730}\n",
    "df = wrapper.read_from_tushare(params)  # 从tushare中读取数据\n",
    "df.to_csv(\"balancesheet_warpper.csv\")\n",
    "wrapper.write_to_db(params)  # 将数据导入数据库并更新缓存\n",
    "\n",
    "print(df.head(5))"
   ],
   "id": "c1b94be3413d2d09",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "数据库中的所有表：\n",
      "daily_000001_sz\n",
      "income_600000_sh\n",
      "数据库中的所有表：\n",
      "daily_000001_sz\n",
      "income_600000_sh\n",
      "600000.SH 20180101 20190730\n",
      "cache missed: 600000.SH is not in checkflags\n",
      "600000.SH 20180101 20190730\n",
      "Table 'balancesheet_600000_sh' created successfully.\n",
      "Data from dataframe has been written to the table balancesheet_600000_sh.\n",
      "Data successfully written to table 'balancesheet_600000_sh'.\n",
      "     ts_code  ann_date f_ann_date  end_date report_type comp_type end_type  \\\n",
      "0  600000.SH  20190430   20190430  20190331           1         2        1   \n",
      "1  600000.SH  20190430   20190430  20190331           1         2        1   \n",
      "2  600000.SH  20190326   20190326  20181231           1         2        4   \n",
      "3  600000.SH  20190326   20190326  20181231           1         2        4   \n",
      "4  600000.SH  20181031   20181031  20180930           1         2        3   \n",
      "\n",
      "    total_share      cap_rese  undistr_porfit  ...  accounts_receiv_bill  \\\n",
      "0  2.935200e+10  8.176000e+10    1.557680e+11  ...                  None   \n",
      "1  2.935200e+10  8.176000e+10    1.557680e+11  ...                  None   \n",
      "2  2.935200e+10  8.176000e+10    1.402080e+11  ...                  None   \n",
      "3  2.935200e+10  8.176000e+10    1.402080e+11  ...                  None   \n",
      "4  2.935200e+10  8.176000e+10    1.284560e+11  ...                  None   \n",
      "\n",
      "  accounts_pay oth_rcv_total  fix_assets_total cip_total oth_pay_total  \\\n",
      "0         None          None              None      None          None   \n",
      "1         None          None              None      None          None   \n",
      "2         None          None              None      None          None   \n",
      "3         None          None              None      None          None   \n",
      "4         None          None              None      None          None   \n",
      "\n",
      "  long_pay_total   debt_invest oth_debt_invest  update_flag  \n",
      "0           None  1.271052e+12    4.040280e+11            0  \n",
      "1           None  1.271052e+12    4.040280e+11            1  \n",
      "2           None  1.144249e+12    3.788600e+11            0  \n",
      "3           None  1.144249e+12    3.788600e+11            1  \n",
      "4           None           NaN             NaN            1  \n",
      "\n",
      "[5 rows x 152 columns]\n"
     ]
    }
   ],
   "execution_count": 3
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-03-03T02:01:22.116717Z",
     "start_time": "2025-03-03T02:01:21.887488Z"
    }
   },
   "cell_type": "code",
   "source": [
    "#4.接口：cashflow\n",
    "\n",
    "from cashflow_warpper import *\n",
    "\n",
    "wrapper = CashFlowWarpper()\n",
    "\n",
    "params = {'ts_code': '600000.SH', 'startdate': 20160101, 'enddate': 20190730}\n",
    "df = wrapper.read_from_tushare(params)  # 从tushare中读取数据\n",
    "\n",
    "df.to_csv(\"cashflow_warpper.csv\")\n",
    "\n",
    "wrapper.write_to_db(params)  # 将数据导入数据库并更新缓存\n",
    "\n",
    "print(df.head(5))"
   ],
   "id": "b2f8c1089ce3dd22",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "数据库中的所有表：\n",
      "balancesheet_600000_sh\n",
      "cashflow_600000_sh\n",
      "daily_000001_sz\n",
      "income_600000_sh\n",
      "File 'C:\\Users\\nianaiyang\\Desktop\\vnpy\\vnpy\\tushare_mirror\\cashflowcached.json' exists.\n",
      "数据库中的所有表：\n",
      "balancesheet_600000_sh\n",
      "cashflow_600000_sh\n",
      "daily_000001_sz\n",
      "income_600000_sh\n",
      "600000.SH 20160101 20190730\n",
      "cache hit\n",
      "     ts_code  ann_date f_ann_date  end_date comp_type report_type end_type  \\\n",
      "0  600000.SH  20190430   20190430  20190331         2           1        1   \n",
      "1  600000.SH  20190326   20190326  20181231         2           1        4   \n",
      "2  600000.SH  20190326   20190326  20181231         2           1        4   \n",
      "3  600000.SH  20181031   20181031  20180930         2           1        3   \n",
      "4  600000.SH  20180830   20180830  20180630         2           1        2   \n",
      "\n",
      "      net_profit finan_exp c_fr_sale_sg  ... net_dism_capital_add  \\\n",
      "0         NODATA    NODATA       NODATA  ...        13327000000.0   \n",
      "1  56515000000.0    NODATA       NODATA  ...        31518000000.0   \n",
      "2  56515000000.0    NODATA       NODATA  ...        31518000000.0   \n",
      "3         NODATA    NODATA       NODATA  ...               NODATA   \n",
      "4  28900000000.0    NODATA       NODATA  ...               NODATA   \n",
      "\n",
      "  net_cash_rece_sec credit_impa_loss use_right_asset_dep oth_loss_asset  \\\n",
      "0            NODATA           NODATA              NODATA         NODATA   \n",
      "1            NODATA           NODATA              NODATA         NODATA   \n",
      "2            NODATA           NODATA              NODATA         NODATA   \n",
      "3            NODATA           NODATA              NODATA         NODATA   \n",
      "4            NODATA           NODATA              NODATA         NODATA   \n",
      "\n",
      "     end_bal_cash    beg_bal_cash end_bal_cash_equ  beg_bal_cash_equ  \\\n",
      "0          NODATA          NODATA           NODATA            NODATA   \n",
      "1  187644000000.0  147458000000.0           NODATA            NODATA   \n",
      "2  187644000000.0  147458000000.0           NODATA            NODATA   \n",
      "3          NODATA          NODATA           NODATA            NODATA   \n",
      "4  162307000000.0  147458000000.0           NODATA            NODATA   \n",
      "\n",
      "  update_flag  \n",
      "0           1  \n",
      "1           0  \n",
      "2           1  \n",
      "3           0  \n",
      "4           1  \n",
      "\n",
      "[5 rows x 97 columns]\n"
     ]
    }
   ],
   "execution_count": 5
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-03-03T02:11:31.079001Z",
     "start_time": "2025-03-03T02:11:30.641379Z"
    }
   },
   "cell_type": "code",
   "source": [
    "#5.接口：forecast\n",
    "\n",
    "from forecast_warpper import *\n",
    "\n",
    "wrapper = ForecastWarpper()\n",
    "\n",
    "params = {'ts_code': '000001.SZ', 'startdate': 20000101, 'enddate': 20220226}\n",
    "df = wrapper.read_from_tushare(params)  # 从 Tushare 中读取数据\n",
    "df.to_csv(\"forecast_warpper.csv\")\n",
    "wrapper.write_to_db(params)  # 将数据导入数据库并更新缓存\n",
    "\n",
    "print(df.head(5))"
   ],
   "id": "a50ac1fcd6569152",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "数据库中的所有表：\n",
      "balancesheet_600000_sh\n",
      "cashflow_000001_sz\n",
      "cashflow_600000_sh\n",
      "daily_000001_sz\n",
      "express_000001_sz\n",
      "income_600000_sh\n",
      "数据库中的所有表：\n",
      "balancesheet_600000_sh\n",
      "cashflow_000001_sz\n",
      "cashflow_600000_sh\n",
      "daily_000001_sz\n",
      "express_000001_sz\n",
      "income_600000_sh\n",
      "000001.SZ 20000101 20220226\n",
      "cache missed: 000001.SZ is not in checkflags\n",
      "000001.SZ 20000101 20220226\n",
      "Table 'forecast_000001_sz' created successfully.\n",
      "Data from dataframe has been written to the table forecast_000001_sz.\n",
      "Data successfully written to table 'forecast_000001_sz'.\n",
      "     ts_code  ann_date  end_date type  p_change_min p_change_max  \\\n",
      "0  000001.SZ  20160121  20151231   略增           5.0         15.0   \n",
      "1  000001.SZ  20120130  20111231   预增          60.0         70.0   \n",
      "2  000001.SZ  20111015  20110930   预增          60.0         70.0   \n",
      "3  000001.SZ  20110713  20110630   预增          50.0         60.0   \n",
      "4  000001.SZ  20110414  20110331   预增          50.0         60.0   \n",
      "\n",
      "  net_profit_min net_profit_max  last_parent_net first_ann_date  \\\n",
      "0      2079206.0      2277225.0        1980200.0       20160121   \n",
      "1       999446.0      1061912.0         628381.6       20120130   \n",
      "2       754914.0       802096.0         473394.0       20111015   \n",
      "3       454968.0       485299.0         303311.9       20110713   \n",
      "4       236718.0       252499.0         157811.8       20110414   \n",
      "\n",
      "                               summary change_reason update_flag  \n",
      "0                预计净利润2079206-2277225万        NODATA           1  \n",
      "1  净利润约999,446万元~1,061,912万元,增长60%~70%        NODATA           1  \n",
      "2     净利润754,914万元~802,096万元,增长60%~70%        NODATA           1  \n",
      "3    净利润约454,968万元~485,299万元,增长50%~60%        NODATA           1  \n",
      "4      净利润约236718万元~252499万元,增长50%~60%        NODATA           1  \n"
     ]
    }
   ],
   "execution_count": 12
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-03-03T02:10:45.123143Z",
     "start_time": "2025-03-03T02:10:44.727533Z"
    }
   },
   "cell_type": "code",
   "source": [
    "#6.接口：express\n",
    "\n",
    "from express_warpper import *\n",
    "\n",
    "wrapper = ExpressWarpper()\n",
    "\n",
    "params = {'ts_code': '000001.SZ', 'startdate': 20110101, 'enddate': 20220226}\n",
    "df = wrapper.read_from_tushare(params)  # 从tushare中读取数据\n",
    "df.to_csv(\"express_warpper.csv\")\n",
    "wrapper.write_to_db(params)  # 将数据导入数据库并更新缓存\n",
    "\n",
    "print(df.head(5))"
   ],
   "id": "8457eb71c3aa3ac2",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "数据库中的所有表：\n",
      "balancesheet_600000_sh\n",
      "cashflow_000001_sz\n",
      "cashflow_600000_sh\n",
      "daily_000001_sz\n",
      "income_600000_sh\n",
      "数据库中的所有表：\n",
      "balancesheet_600000_sh\n",
      "cashflow_000001_sz\n",
      "cashflow_600000_sh\n",
      "daily_000001_sz\n",
      "income_600000_sh\n",
      "000001.SZ 20110101 20220226\n",
      "cache missed: 000001.SZ is not in checkflags\n",
      "000001.SZ 20110101 20220226\n",
      "Table 'express_000001_sz' created successfully.\n",
      "Data from dataframe has been written to the table express_000001_sz.\n",
      "Data successfully written to table 'express_000001_sz'.\n",
      "     ts_code  ann_date  end_date       revenue  operate_profit  total_profit  \\\n",
      "0  000001.SZ  20220114  20211231  1.693830e+11    4.598500e+10  4.587900e+10   \n",
      "1  000001.SZ  20200114  20191231  1.379580e+11    3.628900e+10  3.624000e+10   \n",
      "2  000001.SZ  20190104  20181231  1.167160e+11    3.230500e+10  3.223100e+10   \n",
      "\n",
      "       n_income  total_assets  \n",
      "0  3.633600e+10  4.921380e+12  \n",
      "1  2.819500e+10  3.939070e+12  \n",
      "2  2.481800e+10  3.420753e+12  \n"
     ]
    }
   ],
   "execution_count": 11
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-03-03T02:11:56.324077Z",
     "start_time": "2025-03-03T02:11:55.941163Z"
    }
   },
   "cell_type": "code",
   "source": [
    "#7.接口：dividend\n",
    "\n",
    "from dividend_warpper import *\n",
    "\n",
    "wrapper = DividendWarpper()\n",
    "\n",
    "params = {'ts_code': '600848.SH', 'startdate': 20180101, 'enddate': 20220226}\n",
    "df = wrapper.read_from_tushare(params)  # 从tushare中读取数据\n",
    "df.to_csv(\"dividend_warpper.csv\")\n",
    "wrapper.write_to_db(params)  # 将数据导入数据库并更新缓存\n",
    "\n",
    "print(df.head(5))\n"
   ],
   "id": "1d21df3dcc7b0976",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "数据库中的所有表：\n",
      "balancesheet_600000_sh\n",
      "cashflow_000001_sz\n",
      "cashflow_600000_sh\n",
      "daily_000001_sz\n",
      "express_000001_sz\n",
      "forecast_000001_sz\n",
      "income_600000_sh\n",
      "数据库中的所有表：\n",
      "balancesheet_600000_sh\n",
      "cashflow_000001_sz\n",
      "cashflow_600000_sh\n",
      "daily_000001_sz\n",
      "express_000001_sz\n",
      "forecast_000001_sz\n",
      "income_600000_sh\n",
      "600848.SH 20180101 20220226\n",
      "cache missed: 600848.SH is not in checkflags\n",
      "600848.SH 20180101 20220226\n",
      "Table 'dividend_600848_sh' created successfully.\n",
      "Data from dataframe has been written to the table dividend_600848_sh.\n",
      "Data successfully written to table 'dividend_600848_sh'.\n",
      "     ts_code div_proc  stk_div record_date   ex_date\n",
      "0  600848.SH       预案      0.0        None      None\n",
      "1  600848.SH       预案      0.0        None      None\n",
      "2  600848.SH   股东大会通过      0.0        None      None\n",
      "3  600848.SH       实施      0.0    20240726  20240729\n",
      "4  600848.SH       预案      0.0        None      None\n"
     ]
    }
   ],
   "execution_count": 13
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-03-03T02:12:42.520011Z",
     "start_time": "2025-03-03T02:12:41.914871Z"
    }
   },
   "cell_type": "code",
   "source": [
    "#8.接口：fina_indicator\n",
    "\n",
    "from fina_indicator_warpper import *\n",
    "\n",
    "wrapper = FinaIndicatorWarpper()\n",
    "\n",
    "params = {'ts_code': '600000.SH', 'start_date': 20150101, 'end_date': 20220226}\n",
    "df = wrapper.read_from_tushare(params)  # 从tushare中读取数据\n",
    "df.to_csv(\"fina_indicator_warpper.csv\")\n",
    "wrapper.write_to_db(params)  # 将数据导入数据库并更新缓存\n",
    "\n",
    "print(df.head(5))"
   ],
   "id": "48d2b9c7c81a392",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "数据库中的所有表：\n",
      "balancesheet_600000_sh\n",
      "cashflow_000001_sz\n",
      "cashflow_600000_sh\n",
      "daily_000001_sz\n",
      "dividend_600848_sh\n",
      "express_000001_sz\n",
      "forecast_000001_sz\n",
      "income_600000_sh\n",
      "数据库中的所有表：\n",
      "balancesheet_600000_sh\n",
      "cashflow_000001_sz\n",
      "cashflow_600000_sh\n",
      "daily_000001_sz\n",
      "dividend_600848_sh\n",
      "express_000001_sz\n",
      "forecast_000001_sz\n",
      "income_600000_sh\n",
      "600000.SH 20150101 20220226\n",
      "cache missed: 600000.SH is not in checkflags\n",
      "600000.SH 20150101 20220226\n",
      "Table 'fina_indicator_600000_sh' created successfully.\n",
      "Data from dataframe has been written to the table fina_indicator_600000_sh.\n",
      "Data successfully written to table 'fina_indicator_600000_sh'.\n",
      "     ts_code  ann_date  end_date   eps  dt_eps  total_revenue_ps  revenue_ps  \\\n",
      "0  600000.SH  20241031  20240930  1.13    1.03            4.4235      4.4235   \n",
      "1  600000.SH  20240820  20240630  0.89    0.82            3.0065      3.0065   \n",
      "2  600000.SH  20240430  20240331  0.57    0.52            1.5443      1.5443   \n",
      "3  600000.SH  20240430  20231231  1.07    0.99            5.9087      5.9087   \n",
      "4  600000.SH  20231028  20230930  0.88    0.82            4.5249      4.5249   \n",
      "\n",
      "   capital_rese_ps  surplus_rese_ps  undist_profit_ps  ...   ocf_yoy  roe_yoy  \\\n",
      "0           2.7910           6.5488            7.6194  ... -248.4993  24.6382   \n",
      "1           2.7913           6.5488            7.3974  ... -889.1804  11.5671   \n",
      "2           2.7856           6.4366            7.6649  ... -537.6662   5.7282   \n",
      "3           2.7856           6.4366            7.0977  ...    6.3813 -30.9356   \n",
      "4           2.7856           6.4366            6.9123  ...  563.6181 -33.1222   \n",
      "\n",
      "  bps_yoy assets_yoy eqt_yoy  tr_yoy  or_yoy q_sales_yoy  q_op_qoq  equity_yoy  \n",
      "0  4.5300     4.5440 -0.2818 -2.2407 -2.2407      0.0144  -37.3847      0.9797  \n",
      "1  3.3400     2.7370  2.8660 -3.2687 -3.2687     -0.5353  -51.5543      4.5463  \n",
      "2  2.9600     0.5132  2.5187 -5.7218 -5.7218     -5.7218  128.4640      4.0816  \n",
      "3  4.5900     3.4763  3.8513 -8.0521 -8.0521     -9.6191   69.9333      3.8513  \n",
      "4  3.0462     1.1910  2.5539 -7.5619 -7.5619     -7.6628  -25.6977      3.4216  \n",
      "\n",
      "[5 rows x 108 columns]\n"
     ]
    }
   ],
   "execution_count": 14
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-03-03T02:14:03.472333Z",
     "start_time": "2025-03-03T02:14:03.063221Z"
    }
   },
   "cell_type": "code",
   "source": [
    "#9.接口：fina_audit\n",
    "\n",
    "from fina_audit_warpper import *\n",
    "\n",
    "wrapper = FinaAuditWarpper()\n",
    "\n",
    "params = {'ts_code': '600000.SH', 'start_date': 20070101, 'end_date': 20200808}\n",
    "df = wrapper.read_from_tushare(params)  # 从tushare中读取数据\n",
    "df.to_csv(\"fina_audit_warpper.csv\")\n",
    "wrapper.write_to_db(params)  # 将数据导入数据库并更新缓存\n",
    "\n",
    "print(df.head(5))"
   ],
   "id": "77bdec275e5243f2",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "数据库中的所有表：\n",
      "balancesheet_600000_sh\n",
      "cashflow_000001_sz\n",
      "cashflow_600000_sh\n",
      "daily_000001_sz\n",
      "dividend_600848_sh\n",
      "express_000001_sz\n",
      "fina_indicator_600000_sh\n",
      "forecast_000001_sz\n",
      "income_600000_sh\n",
      "数据库中的所有表：\n",
      "balancesheet_600000_sh\n",
      "cashflow_000001_sz\n",
      "cashflow_600000_sh\n",
      "daily_000001_sz\n",
      "dividend_600848_sh\n",
      "express_000001_sz\n",
      "fina_indicator_600000_sh\n",
      "forecast_000001_sz\n",
      "income_600000_sh\n",
      "600000.SH 20070101 20200808\n",
      "cache missed: 600000.SH is not in checkflags\n",
      "600000.SH 20070101 20200808\n",
      "Table 'fina_audit_600000_sh' created successfully.\n",
      "Data from dataframe has been written to the table fina_audit_600000_sh.\n",
      "Data successfully written to table 'fina_audit_600000_sh'.\n",
      "     ts_code  ann_date  end_date audit_result audit_fees  audit_agency  \\\n",
      "0  600000.SH  20200425  20191231      标准无保留意见  5700000.0   毕马威华振会计师事务所   \n",
      "1  600000.SH  20190326  20181231      标准无保留意见  8020000.0  普华永道中天会计师事务所   \n",
      "2  600000.SH  20180428  20171231      标准无保留意见  7070000.0  普华永道中天会计师事务所   \n",
      "3  600000.SH  20170401  20161231      标准无保留意见     NODATA  普华永道中天会计师事务所   \n",
      "4  600000.SH  20160407  20151231      标准无保留意见     NODATA  普华永道中天会计师事务所   \n",
      "\n",
      "  audit_sign  \n",
      "0    石海云,窦友明  \n",
      "1      周章,张武  \n",
      "2      周章,张武  \n",
      "3      周章,张武  \n",
      "4      胡亮,张武  \n"
     ]
    }
   ],
   "execution_count": 16
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-03-03T02:15:01.169733Z",
     "start_time": "2025-03-03T02:15:00.685583Z"
    }
   },
   "cell_type": "code",
   "source": [
    "#10.接口：fina_mainbz\n",
    "\n",
    "from fina_mainbz_warpper import *\n",
    "\n",
    "wrapper = FinaMainbzWarpper()\n",
    "\n",
    "params = {'ts_code': '000627.SZ', 'type': 'P'}\n",
    "df = wrapper.read_from_tushare(params)  # 从tushare中读取数据\n",
    "df.to_csv(\"fina_mainbz_warpper.csv\")\n",
    "wrapper.write_to_db(params)  # 将数据导入数据库并更新缓存\n",
    "\n",
    "print(df.head(5))\n"
   ],
   "id": "13cd1a9ed9b365c1",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "数据库中的所有表：\n",
      "balancesheet_600000_sh\n",
      "cashflow_000001_sz\n",
      "cashflow_600000_sh\n",
      "daily_000001_sz\n",
      "dividend_600848_sh\n",
      "express_000001_sz\n",
      "fina_audit_600000_sh\n",
      "fina_indicator_600000_sh\n",
      "forecast_000001_sz\n",
      "income_600000_sh\n",
      "数据库中的所有表：\n",
      "balancesheet_600000_sh\n",
      "cashflow_000001_sz\n",
      "cashflow_600000_sh\n",
      "daily_000001_sz\n",
      "dividend_600848_sh\n",
      "express_000001_sz\n",
      "fina_audit_600000_sh\n",
      "fina_indicator_600000_sh\n",
      "forecast_000001_sz\n",
      "income_600000_sh\n",
      "数据库中的所有表：\n",
      "balancesheet_600000_sh\n",
      "cashflow_000001_sz\n",
      "cashflow_600000_sh\n",
      "daily_000001_sz\n",
      "dividend_600848_sh\n",
      "express_000001_sz\n",
      "fina_audit_600000_sh\n",
      "fina_indicator_600000_sh\n",
      "forecast_000001_sz\n",
      "income_600000_sh\n",
      "数据库中的所有表：\n",
      "balancesheet_600000_sh\n",
      "cashflow_000001_sz\n",
      "cashflow_600000_sh\n",
      "daily_000001_sz\n",
      "dividend_600848_sh\n",
      "express_000001_sz\n",
      "fina_audit_600000_sh\n",
      "fina_indicator_600000_sh\n",
      "forecast_000001_sz\n",
      "income_600000_sh\n",
      "000627.SZ None 20250302\n",
      "invalid parameters\n",
      "000627.SZ None 20250302\n",
      "Table 'fina_mainbz_000627_sz' created successfully.\n",
      "Data from dataframe has been written to the table fina_mainbz_000627_sz.\n",
      "Data successfully written to table 'fina_mainbz_000627_sz'.\n",
      "     ts_code  end_date      bz_item bz_code      bz_sales     bz_profit  \\\n",
      "0  000627.SZ  20240630         寿险业务       P  2.805776e+10  -307534700.0   \n",
      "1  000627.SZ  20240630          其他类       P  2.591522e+08   103067500.0   \n",
      "2  000627.SZ  20240630  健康及意外伤害保险业务       P  6.275057e+08  -221127400.0   \n",
      "3  000627.SZ  20231231         寿险业务       P  4.799409e+10 -2096593600.0   \n",
      "4  000627.SZ  20231231  健康及意外伤害保险业务       P  1.274255e+09   233187500.0   \n",
      "\n",
      "         bz_cost curr_type  \n",
      "0  28365290800.0       CNY  \n",
      "1    156084700.0       CNY  \n",
      "2    848633100.0       CNY  \n",
      "3  50090686100.0       CNY  \n",
      "4   1041067600.0       CNY  \n"
     ]
    }
   ],
   "execution_count": 17
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-03-03T02:15:50.862008Z",
     "start_time": "2025-03-03T02:15:50.496321Z"
    }
   },
   "cell_type": "code",
   "source": [
    "#10.接口：disclosure_date\n",
    "\n",
    "from disclosure_date_warpper import *\n",
    "\n",
    "wrapper = DisclosureDateWarpper()\n",
    "\n",
    "params = {'ts_code': '600848.SH', 'end_date': '20181231'}\n",
    "df = wrapper.read_from_tushare(params)  # 从tushare中读取数据\n",
    "df.to_csv(\"disclosure_date_warpper.csv\")\n",
    "wrapper.write_to_db(params)  # 将数据导入数据库并更新缓存\n",
    "\n",
    "print(df.head(5))"
   ],
   "id": "cf55409fa23e1d15",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "数据库中的所有表：\n",
      "balancesheet_600000_sh\n",
      "cashflow_000001_sz\n",
      "cashflow_600000_sh\n",
      "daily_000001_sz\n",
      "dividend_600848_sh\n",
      "express_000001_sz\n",
      "fina_audit_600000_sh\n",
      "fina_indicator_600000_sh\n",
      "fina_mainbz_000627_sz\n",
      "forecast_000001_sz\n",
      "income_600000_sh\n",
      "数据库中的所有表：\n",
      "balancesheet_600000_sh\n",
      "cashflow_000001_sz\n",
      "cashflow_600000_sh\n",
      "daily_000001_sz\n",
      "dividend_600848_sh\n",
      "express_000001_sz\n",
      "fina_audit_600000_sh\n",
      "fina_indicator_600000_sh\n",
      "fina_mainbz_000627_sz\n",
      "forecast_000001_sz\n",
      "income_600000_sh\n",
      "600848.SH 20181231\n",
      "cache missed: 600848.SH is not in checkflags\n",
      "600848.SH 20181231\n",
      "Table 'disclosure_date_600848_sh' created successfully.\n",
      "Data from dataframe has been written to the table disclosure_date_600848_sh.\n",
      "Data successfully written to table 'disclosure_date_600848_sh'.\n",
      "     ts_code  ann_date  end_date  pre_date actual_date\n",
      "0  600848.SH  20181227  20181231  20190403    20190403\n"
     ]
    }
   ],
   "execution_count": 18
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
